package org

import (
	"fmt"
	"time"
	"dhfshop/models"
)

type FxDistributor struct {
    DistributorId     int64     `orm:"column(distributor_id);pk" json:"distributor_id"`
	PartnerId         int64     `orm:"column(partner_id);index" json:"partner_id"`  
	StoreId           int64     `orm:"column(store_id);index" json:"store_id"`  
	GradeId           int64     `orm:"column(grade_id)" json:"grade_id"`            //等级ID
	SellerUserId      int64     `orm:"column(seller_user_id)" json:"seller_user_id"`
	UserId            int64     `orm:"column(user_id)" json:"user_id"`
	FatherUserId      int64     `orm:"column(father_user_id)" json:"father_user_id"`  
	Check             bool      `orm:"column(check)" json:"check"`                   //是否同意授权
	Introduce         string    `orm:"column(introduce);size(255)" json:"introduce"` //介绍
	Reason            string    `orm:"column(reason);size(255)" json:"reason"`       //拒绝原因
	CreatedTime       time.Time `orm:"auto_now_add;type(datetime);column(created_time)" json:"-"`     
	UpdatedTime       time.Time `orm:"auto_now;type(datetime);column(updated_time)" json:"-"`  
	Phone             string    `orm:"null;column(phone)" json:"phone,omitempty"`
	NickName          string    `orm:"null;column(nick_name)" json:"nick_name"`
	Weixin            string    `orm:"null;column(weixin)" json:"weixin,omitempty"`
	BankAccountName   string    `orm:"column(bank_account_name)" json:"bank_account_name"` 
	BankName          string    `orm:"column(bank_name);size(100);index" json:"bank_name"`        
	BankAccountNumber string    `orm:"column(bank_account_number)" json:"bank_account_number"`
}


func GetFxDistributor(memberId int64) (fxDistributor *FxDistributor, err error) {
	sql := fmt.Sprint("select * from fx_distributor where user_id=%d", memberId)
	o := models.GetDefaultDB()					
	err = o.Raw(sql).QueryRow(fxDistributor)
	return
}
